Multi-User Order Routing

Modified on 2012/01/23 13:20 by Andrew Busby (CTS) — Categorized as: Uncategorized

The API allows a single session to login additional users and submit orders on behalf of those additional users. For example, if you are developing a trading system that is client-server based and only the server will connect to T4 then you can use a single T4API instance to route orders on behalf of multiple T4 users. Doing this would mean that Audit trails correctly show the user responsible for entering the order, the correct user exchange details (such as member id) are sent to the exchange, plus that the fees associated with the order are assigned to that T4 user and not to your master login.

NOTE: A single T4API instance can only support users and accounts from within a single firm. If you need to access users in multiple firms then you will need to use an API instance for each firm. Additionally, different firms have different permissions set, including which exchanges they can see. The exchanges that a firm can see are listed in the Host.MarketData.Exchanges list within the API.

NOTE: It is not recommended that Multi-User order routing functionality be used on a low bandwidth connection.

Before logging in an additional user you must first be logged into the API successfully. No special user or permissions are required for you to log in additional users, you just need to know the username and password for them. However, the additional user you are logging in must have permission set for your application.

To log in an additional user you use the Host.Users.LoginUser function simply passing the username and password:

' Reference to an additional user.
Private WithEvents moUser2 As User



moUser2 = moAPI.Users.LoginUser("Username", "password")

The User object created is added to the Users list and remains there even if login fails. If you call LoginUser with the same Username again then you will be returned the original User object.

NOTE: The Users list will also contain the user you used to login the API originally and it will have its ‘Master’ property set to True.

The login takes place asynchronously, and the User object will raise a LoginSuccess or LoginFailure event when it is complete:

' Event raised if login is successful.
Private Sub moUser2_LoginSuccess(ByVal poUser As T4.API.User) Handles moUser2.LoginSuccess

Trace.WriteLine(String.Format("Login Success for {0}", poUser.Username))

End Sub

' Event raised if login failed.
Private Sub moUser2_LoginFailure(ByVal poUser As T4.API.User, ByVal penReason As T4.LoginResult) Handles moUser2.LoginFailure

Trace.WriteLine(String.Format("Login failed for {0}, Reason: {1}", poUser.Username, penReason))

End Sub

Alternatively, you can check the LoginResult property of the user to get the last login status. This value will be ‘LoginResult.Unknown’ until the login response is received from the server. If login fails then you can try again by calling the LoginUser method again with a new password, otherwise the server will not automatically retry the login attempt by itself.

Once an additional user is logged in it will stay logged in until you shut down the API. There is no way to log out an additional user once they have been logged in. Additionally, if the API is disconnected from the T4 servers then when it reconnects it will automatically re-login all the additional users that were logged in before.

The properties of the User object are described here.

The Accounts list of the individual User objects will contain only those accounts that the individual user can see. The user can only submit orders into those accounts. The master user (that created the API session) has its own list of accounts and does not need to be configured to see the accounts of the additional users that it will be logging in. The main account list at API.Host.Accounts contains all the accounts that the API has loaded, regardless of the user that has access to them. Both the main account list and the user specific account lists raise the same events.

Order Submission